#include "player.hpp"

player::player()
{
    x = 10;
    y = 10;
    pic = load_image("player.bmp", false);
    //pic = SDL_LoadBMP("player.bmp");
    /*SDL_Surface* loadedImage = NULL;

    SDL_Surface* optimizedImage = NULL;

    loadedImage = SDL_LoadBMP( "player.bmp" );

    if( loadedImage != NULL)
    {
        //optimizedImage = SDL_DisplayFormat( loadedImage );
        optimizedImage = loadedImage;
        if( optimizedImage != NULL )
        {
            Uint32 colorkey = SDL_MapRGB( optimizedImage->format, 0xFF, 0, 0xFF );
            SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, colorkey );
        }

        SDL_FreeSurface( loadedImage );
    }
    pic = optimizedImage;*/
}

player::player(int nx, int ny)
{
    x = nx;
    y = ny;
    pic = load_image("player.bmp");
}

void player::move(bool u, bool d, bool l, bool r)
{
    if(u)
        y--;
    if(d)
        y++;
    if(l)
        x--;
    if(r)
        x++;
}
void player::draw(SDL_Surface *screen)
{
    apply_surface(x, y, pic, screen);
}
